import React,{ Component } from 'react'
import UserAdd from './UserAdd'

class UserList extends Component {
    componentDidMount() {
        console.log('----')
        console.log(this.elem)
        this.elem.textInput.value = 'hello'
    }
    render() {
        return (
            <div>
                {this.props.users.map((item, index) => {
                    return (
                    <div key={item.id} onClick={() => {this.props.handleChangeId(item.id)}} >
                        {item.name}
                    </div>)
                })}

                <UserAdd ref={(elem) => {this.elem = elem}} handleListAdd={this.props.handleListAdd}/>
            </div>
        )
    }
}

export default UserList